// var i;
// var $bundleConfig = require("./BundleConfig");
// var $aDManager = require("./ADManager");
// var $eventManager = require("./EventManager");
// var $tipsManager = require("./TipsManager");
// var $uIManager = require("./UIManager");
// var $uIView = require("./UIView");
// var $timeUtils = require("./TimeUtils");
// var $uIRotate = require("./UIRotate");
// var $evenType = require("./EvenType");
// var $playerDataManager = require("./PlayerDataManager");
// var $excel = require("./Excel");
// var $gameDataManager = require("./GameDataManager");
// var $gameGlobalVariable = require("./GameGlobalVariable");
// var $uIConfig_Game = require("./UIConfig_Game");
// var $const_Hall = require("./Const_Hall");
// var $hallGlobalVariable = require("./HallGlobalVariable");
// var $uIConfig_Home = require("./UIConfig_Home");
// var $uI_BoxAward = require("./UI_BoxAward");
// var x = cc._decorator;
// var C = x.ccclass;
// var B = x.property;
// var k = x.inspector;
// var P = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.wujintime = null;
//         t.wujinfenshu = null;
//         t.wujincount = null;
//         t.shaodangBt = null;
//         t.awardBoxs = null;
//         t.awardNode = null;
//         t.startBt = null;
//         t.saodangLb = null;
//         t.kaishiLb = null;
//         t.tagfen = [1500, 3e3, 4500, 6e3];
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
//         this.initWuJinUi();
//     };
//     t.prototype.onDisable = function () {
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
//     };
//     t.prototype._show = function (e) {
//         var t = [];
//         for (var o = 1; o < arguments.length; o++) {
//             t[o - 1] = arguments[o];
//         }
//     };
//     t.prototype.initWuJinUi = function () {
//         var e = $playerDataManager.PlayerDataMgr.getWuJinCount();
//         this.wujincount.string = "今日剩余" + e + "次";
//         this.wujinfenshu.string = "今日累计" + $gameDataManager.GameDataMgr.getTiaoZhanFen(1);
//         if (1 == $gameDataManager.GameDataMgr.getNowLevelPassState(1, 1)) {
//             this.shaodangBt.active = !0;
//         } else {
//             this.shaodangBt.active = !1;
//         }
//         this.initAwardBox();
//         this.saodangLb.string = "×" + $gameGlobalVariable.GameGlobalVariable.wujinsaodangcount;
//         this.kaishiLb.string = "×" + $gameGlobalVariable.GameGlobalVariable.wujintilicount;
//     };
//     t.prototype.initAwardBox = function () {
//         var e = this.awardBoxs.children;
//         for (var t = 0; t < e.length; t++) {
//             var o = e[t];
//             var n = this.tagfen[t];
//             o.children[1].getComponent(cc.Label).string = "累计" + n + "分";
//             if ($gameDataManager.GameDataMgr.getTiaoZhanFen(1) >= n) {
//                 $gameDataManager.GameDataMgr.getTiaoZhanAwardJilu(1, t + 1)
//                     ? ((o.children[0].getChildByName("unlockimg").active = !0),
//                       (o.children[0].getChildByName("lockimg").active = !1),
//                       (o.children[0].getChildByName("redpoint").active = !1),
//                       o.children[0].getComponent($uIRotate.default).stopRotate())
//                     : ((o.children[0].getChildByName("unlockimg").active = !1),
//                       (o.children[0].getChildByName("lockimg").active = !0),
//                       (o.children[0].getChildByName("redpoint").active = !0),
//                       o.children[0].getComponent($uIRotate.default).startRotate());
//             } else {
//                 o.children[0].getChildByName("unlockimg").active = !1;
//                 o.children[0].getChildByName("lockimg").active = !0;
//                 o.children[0].getChildByName("redpoint").active = !1;
//                 o.children[0].getComponent($uIRotate.default).stopRotate();
//             }
//         }
//     };
//     t.prototype.onSaoDang = function () {
//         if (
//             $playerDataManager.PlayerDataMgr.globalData.power >=
//             $gameGlobalVariable.GameGlobalVariable.wujinsaodangcount
//         ) {
//             $playerDataManager.PlayerDataMgr.getWuJinCount() > 0
//                 ? $aDManager.ADMgr.showRewardedVideo("视频扫荡", function () {
//                       $gameGlobalVariable.GameGlobalVariable.nowlevel = -1;
//                       $gameGlobalVariable.GameGlobalVariable.teshulevel = 1;
//                       $playerDataManager.PlayerDataMgr.SubPower(
//                           $gameGlobalVariable.GameGlobalVariable.wujinsaodangcount
//                       );
//                       $playerDataManager.PlayerDataMgr.subWuJinCount(1);
//                       $uIManager.default.open($bundleConfig.BundleNames.Game, $uIConfig_Game.UIView_Game.UI_GameOver, {
//                           type: 2,
//                           back: function () {}
//                       });
//                   })
//                 : $tipsManager.TipMgr.showToast("今日挑战次数用尽");
//         } else {
//             $tipsManager.TipMgr.showToast("体力不足");
//         }
//     };
//     t.prototype.showTip = function () {
//         $uIManager.default.open($bundleConfig.BundleNames.Home, $uIConfig_Home.UIView_Home.UI_ShuoMing);
//     };
//     t.prototype.onStartGame = function () {
//         if (
//             $playerDataManager.PlayerDataMgr.globalData.power >= $gameGlobalVariable.GameGlobalVariable.wujintilicount
//         ) {
//             $playerDataManager.PlayerDataMgr.getWuJinCount() > 0
//                 ? ($playerDataManager.PlayerDataMgr.SubPower($gameGlobalVariable.GameGlobalVariable.wujintilicount),
//                   $eventManager.EventMgr.dispatchEvent($evenType.EVENT_TYPE.GAME_TIAOZHAN_VIEW),
//                   this._close())
//                 : $tipsManager.TipMgr.showToast("今日挑战次数用尽");
//         } else {
//             $tipsManager.TipMgr.showToast("体力不足");
//         }
//     };
//     t.prototype.onAwardBoxClick = function (e, t) {
//         var o = this.tagfen[Number(t) - 1];
//         var n = $gameDataManager.GameDataMgr.getTiaoZhanFen(1);
//         var i = $excel.Excel.shuiguoguanqia(5);
//         if (n < o) {
//             var a = e.getCurrentTarget();
//             this.awardNode.getComponent($uI_BoxAward.default).showAward(a, i, t, 2);
//         } else {
//             if ($gameDataManager.GameDataMgr.getTiaoZhanAwardJilu(1, Number(t))) {
//                 $tipsManager.TipMgr.showToast("已领取");
//             } else {
//                 {
//                     $tipsManager.TipMgr.showToast("恭喜获得奖励");
//                     switch (t) {
//                         case "1":
//                             this.getAwardData(i.tiaozhanbox1);
//                             break;
//                         case "2":
//                             this.getAwardData(i.tiaozhanbox2);
//                             break;
//                         case "3":
//                             this.getAwardData(i.tiaozhanbox3);
//                             break;
//                         case "4":
//                             this.getAwardData(i.tiaozhanbox4);
//                     }
//                     $gameDataManager.GameDataMgr.unTiaoZhanAwardJiLu(1, Number(t));
//                 }
//             }
//             this.initAwardBox();
//         }
//     };
//     t.prototype.getAwardData = function (e) {
//         var t = new $const_Hall.GetItemsData();
//         t.ids = [];
//         t.counts = [];
//         for (var o = 0; o < e.length; o++) {
//             var n = e[o];
//             switch (n[0]) {
//                 case 1:
//                     t.ids.push($hallGlobalVariable.default.goldId);
//                     t.counts.push(n[1]);
//                     break;
//                 case 2:
//                     t.ids.push($hallGlobalVariable.default.diamondId);
//                     t.counts.push(n[1]);
//                     break;
//                 case 3:
//                     t.ids.push($hallGlobalVariable.default.powerId);
//                     t.counts.push(n[1]);
//                     break;
//                 case 5:
//                     var i = null;
//                     if (1 == n[1]) {
//                         i = $hallGlobalVariable.default.GetSuiPian([n[2], 0, 0]);
//                     }
//                     if (2 == n[1]) {
//                         i = $hallGlobalVariable.default.GetSuiPian([0, n[2], 0]);
//                     }
//                     if (3 == n[1]) {
//                         i = $hallGlobalVariable.default.GetSuiPian([0, 0, n[2]]);
//                     }
//                     i.forEach(function (e, o) {
//                         t.ids.push(o);
//                         t.counts.push(e);
//                     });
//             }
//         }
//         t.clickCallBack = function () {
//             for (var e = 0; e < t.ids.length; e++) {
//                 var o = t.ids[e];
//                 var n = t.counts[e];
//                 switch (o) {
//                     case $hallGlobalVariable.default.goldId:
//                         $eventManager.EventMgr.dispatchEvent($evenType.EVENT_TYPE.Home_Add_Gold, 2, n);
//                         break;
//                     case $hallGlobalVariable.default.diamondId:
//                         $eventManager.EventMgr.dispatchEvent($evenType.EVENT_TYPE.Home_Add_Gold, 3, n);
//                         break;
//                     case $hallGlobalVariable.default.powerId:
//                         $eventManager.EventMgr.dispatchEvent($evenType.EVENT_TYPE.Home_Add_Gold, 1, n);
//                         break;
//                     default:
//                         $tipsManager.TipMgr.showToast("恭喜获得水果碎片");
//                         $playerDataManager.PlayerDataMgr.AddEquipFragments(o, n);
//                 }
//             }
//         };
//         $uIManager.default.open($bundleConfig.BundleNames.Home, $uIConfig_Home.UIView_Home.UI_GetItems, t);
//     };
//     t.prototype.update = function () {
//         this.wujintime.string =
//             $timeUtils.default.secondsToHMS($timeUtils.default.getTimeUntilMidnight() / 1e3) + "刷新";
//     };
//     t.prototype.onCloseView = function () {
//         this._close();
//     };
//     __decorate([B(cc.Label)], t.prototype, "wujintime", void 0);
//     __decorate([B(cc.Label)], t.prototype, "wujinfenshu", void 0);
//     __decorate([B(cc.Label)], t.prototype, "wujincount", void 0);
//     __decorate([B(cc.Node)], t.prototype, "shaodangBt", void 0);
//     __decorate([B(cc.Node)], t.prototype, "awardBoxs", void 0);
//     __decorate([B(cc.Node)], t.prototype, "awardNode", void 0);
//     __decorate([B(cc.Node)], t.prototype, "startBt", void 0);
//     __decorate([B(cc.Label)], t.prototype, "saodangLb", void 0);
//     __decorate([B(cc.Label)], t.prototype, "kaishiLb", void 0);
//     return __decorate([C], t);
// })($uIView.default);
// exports.default = P;

// import { ADMgr } from "./ADManager";
// import { BundleNames } from "./BundleConfig";
// import { GetItemsData } from "./Const_Hall";
// import { EVENT_TYPE } from "./EvenType";
// import { EventMgrInstance } from "./EventManager";
// import { Excel } from "./Excel";
// import { GameDataMgr } from "./GameDataManager";
// import { GameGlobalVariable } from "./GameGlobalVariable";
// import HallGlobalVariable from "./HallGlobalVariable";
// import { PlayerDataMgr } from "./PlayerDataManager";
// import TimeUtils from "./TimeUtils";
// import { TipMgrInstance } from "./TipsManager";
// import { UIView_Game } from "./UIConfig_Game";
// import { UIView_Home } from "./UIConfig_Home";
// import UIManager from "./UIManager";
// import UIRotate from "./UIRotate";
// import UIView from "./UIView";
// import UI_BoxAward from "./UI_BoxAward";


// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名：EndlessModeUI
//  */
// @ccclass
// export default class UI_WuJinTiaoZhan extends UIView {
//     @property(cc.Label)
//     public wujintime: cc.Label = null;

//     @property(cc.Label)
//     public wujinfenshu: cc.Label = null;

//     @property(cc.Label)
//     public wujincount: cc.Label = null;

//     @property(cc.Node)
//     public shaodangBt: cc.Node = null;

//     @property(cc.Node)
//     public awardBoxs: cc.Node = null;

//     @property(cc.Node)
//     public awardNode: cc.Node = null;

//     @property(cc.Node)
//     public startBt: cc.Node = null;

//     @property(cc.Label)
//     public saodangLb: cc.Label = null;

//     @property(cc.Label)
//     public kaishiLb: cc.Label = null;

//     private tagfen: number[] = [1500, 3000, 4500, 6000];

//     onEnable() {
//         EventMgrInstance.addEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         EventMgrInstance.addEventListener(EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
//         EventMgrInstance.addEventListener(EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
//         this.initWuJinUi();
//     }

//     onDisable() {
//         EventMgrInstance.rmEventListener(EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
//         EventMgrInstance.rmEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         EventMgrInstance.rmEventListener(EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
//     }

//     protected _show(event: any, ...args: any[]) {
//         // Method implementation
//     }

//     /**
//      * 初始化无限模式UI。
//      * 建议方法名：initializeEndlessModeUI
//      */
//     private initWuJinUi() {
//         const wuJinCount = PlayerDataMgr.getWuJinCount();
//         this.wujincount.string = `今日剩余${wuJinCount}次`;
//         this.wujinfenshu.string = `今日累计${GameDataMgr.getTiaoZhanFen(1)}`;

//         this.shaodangBt.active = GameDataMgr.getNowLevelPassState(1, 1) === 1;

//         this.initAwardBox();
//         this.saodangLb.string = `×${GameGlobalVariable.wujinsaodangcount}`;
//         this.kaishiLb.string = `×${GameGlobalVariable.wujintilicount}`;
//     }

//     /**
//      * 初始化奖励盒子。
//      * 建议方法名：initializeAwardBox
//      */
//     private initAwardBox() {
//         const awardBoxChildren = this.awardBoxs.children;
//         awardBoxChildren.forEach((box, index) => {
//             const requiredScore = this.tagfen[index];
//             box.children[1].getComponent(cc.Label).string = `累计${requiredScore}分`;

//             this.updateBoxStatus(box, requiredScore, index);
//         });
//     }

//     private updateBoxStatus(box: cc.Node, score: number, index: number) {
//         if (GameDataMgr.getTiaoZhanFen(1) >= score) {
//             if (GameDataMgr.getTiaoZhanAwardJilu(1, index + 1)) {
//                 this.setBoxStatus(box, true, false, false);
//                 box.children[0].getComponent(UIRotate).stopRotate();
//             } else {
//                 this.setBoxStatus(box, false, true, true);
//                 box.children[0].getComponent(UIRotate).startRotate();
//             }
//         } else {
//             this.setBoxStatus(box, false, true, false);
//             box.children[0].getComponent(UIRotate).stopRotate();
//         }
//     }

//     /**
//      * 设置奖励盒子的状态。
//      * 建议方法名：setAwardBoxStatus
//      */
//     private setBoxStatus(box: cc.Node, unlock: boolean, lock: boolean, redPoint: boolean) {
//         box.children[0].getChildByName('unlockimg').active = unlock;
//         box.children[0].getChildByName('lockimg').active = lock;
//         box.children[0].getChildByName('redpoint').active = redPoint;
//     }

//     /**
//      * 扫荡按钮点击事件。
//      * 建议方法名：handleSaoDangClick
//      */
//     onSaoDang() {
//         if (PlayerDataMgr.globalData.power >= GameGlobalVariable.wujinsaodangcount) {
//             if (PlayerDataMgr.getWuJinCount() > 0) {
//                 ADMgr.showRewardedVideo('视频扫荡', () => {
//                     GameGlobalVariable.nowlevel = -1;
//                     GameGlobalVariable.teshulevel = 1;
//                     PlayerDataMgr.SubPower(GameGlobalVariable.wujinsaodangcount);
//                     PlayerDataMgr.subWuJinCount(1);
//                     UIManager.open(BundleNames.Game, UIView_Game.UI_GameOver, {
//                         type: 2,
//                         back: () => { },
//                     });
//                 });
//             } else {
//                 TipMgrInstance.showToast('今日挑战次数用尽');
//             }
//         } else {
//             TipMgrInstance.showToast('体力不足');
//         }
//     }

//     /**
//      * 显示提示信息。
//      * 建议方法名：showInformationTip
//      */
//     showTip() {
//         UIManager.open(BundleNames.Home, UIView_Home.UI_ShuoMing);
//     }

//     /**
//      * 开始游戏按钮点击事件。
//      * 建议方法名：handleStartGameClick
//      */
//     onStartGame() {
//         if (PlayerDataMgr.globalData.power >= GameGlobalVariable.wujintilicount) {
//             if (PlayerDataMgr.getWuJinCount() > 0) {
//                 PlayerDataMgr.SubPower(GameGlobalVariable.wujintilicount);
//                 EventMgrInstance.dispatchEvent(EVENT_TYPE.GAME_TIAOZHAN_VIEW);
//                 this._close();
//             } else {
//                 TipMgrInstance.showToast('今日挑战次数用尽');
//             }
//         } else {
//             TipMgrInstance.showToast('体力不足');
//         }
//     }

//     /**
//      * 奖励盒子点击事件。
//      * 建议方法名：handleAwardBoxClick
//      */
//     onAwardBoxClick(event: cc.Event, boxIndex: string) {
//         const requiredScore = this.tagfen[Number(boxIndex) - 1];
//         const currentScore = GameDataMgr.getTiaoZhanFen(1);
//         const awardData = Excel.shuiguoguanqia(5);

//         if (currentScore < requiredScore) {
//             this.awardNode.getComponent(UI_BoxAward).showAward(event.getCurrentTarget(), awardData, boxIndex, 2);
//         } else if (GameDataMgr.getTiaoZhanAwardJilu(1, Number(boxIndex))) {
//             TipMgrInstance.showToast('已领取');
//         } else {
//             TipMgrInstance.showToast('恭喜获得奖励');
//             this.getAwardDataByBoxIndex(awardData, boxIndex);
//             GameDataMgr.unTiaoZhanAwardJiLu(1, Number(boxIndex));
//             this.initAwardBox();
//         }
//     }

//     /**
//      * 根据箱子索引获取奖励数据。
//      * 建议方法名：getAwardDataByBoxIndex
//      */
//     private getAwardDataByBoxIndex(data: any, boxIndex: string) {
//         switch (boxIndex) {
//             case '1':
//                 this.getAwardData(data.tiaozhanbox1);
//                 break;
//             case '2':
//                 this.getAwardData(data.tiaozhanbox2);
//                 break;
//             case '3':
//                 this.getAwardData(data.tiaozhanbox3);
//                 break;
//             case '4':
//                 this.getAwardData(data.tiaozhanbox4);
//         }
//     }

//     /**
//      * 获取奖励数据。
//      * 建议方法名：fetchAwardData
//      */
//     private getAwardData(dataArray: any[]) {
//         let awardData = new GetItemsData();
//         awardData.ids = [];
//         awardData.counts = [];

//         dataArray.forEach((data) => {
//             const [type, count, fragment] = data;
//             switch (type) {
//                 case 1:
//                     awardData.ids.push(HallGlobalVariable.goldId);
//                     awardData.counts.push(count);
//                     break;
//                 case 2:
//                     awardData.ids.push(HallGlobalVariable.diamondId);
//                     awardData.counts.push(count);
//                     break;
//                 case 3:
//                     awardData.ids.push(HallGlobalVariable.powerId);
//                     awardData.counts.push(count);
//                     break;
//                 case 5:
//                     const fragments = this.getFragmentData(fragment);
//                     fragments.forEach((fragmentCount, id) => {
//                         awardData.ids.push(id);
//                         awardData.counts.push(fragmentCount);
//                     });
//                     break;
//             }
//         });

//         awardData.clickCallBack = this.createAwardCallback(awardData);
//         UIManager.open(BundleNames.Home, UIView_Home.UI_GetItems, awardData);
//     }

//     private getFragmentData(fragment: any): Map<number, number> {
//         let fragmentData: Map<number, number> = new Map();
//         if (fragment === 1) {
//             fragmentData = HallGlobalVariable.GetSuiPian([fragment, 0, 0]);
//         } else if (fragment === 2) {
//             fragmentData = HallGlobalVariable.GetSuiPian([0, fragment, 0]);
//         } else if (fragment === 3) {
//             fragmentData = HallGlobalVariable.GetSuiPian([0, 0, fragment]);
//         }
//         return fragmentData;
//     }

//     private createAwardCallback(awardData: GetItemsData): () => void {
//         return () => {
//             awardData.ids.forEach((id: number, index: number) => {
//                 const count = awardData.counts[index];
//                 this.dispatchAwardEvent(id, count);
//             });
//         };
//     }

//     private dispatchAwardEvent(id: number, count: number) {
//         switch (id) {
//             case HallGlobalVariable.goldId:
//                 EventMgrInstance.dispatchEvent(EVENT_TYPE.Home_Add_Gold, 2, count);
//                 break;
//             case HallGlobalVariable.diamondId:
//                 EventMgrInstance.dispatchEvent(EVENT_TYPE.Home_Add_Gold, 3, count);
//                 break;
//             case HallGlobalVariable.powerId:
//                 EventMgrInstance.dispatchEvent(EVENT_TYPE.Home_Add_Gold, 1, count);
//                 break;
//             default:
//                 TipMgrInstance.showToast('恭喜获得水果碎片');
//                 PlayerDataMgr.AddEquipFragments(id, count);
//         }
//     }

//     /**
//      * 更新方法。
//      * 建议方法名：updateRemainingTime
//      */
//     update() {
//         this.wujintime.string = `${TimeUtils.secondsToHMS(TimeUtils.getTimeUntilMidnight() / 1000)}刷新`;
//     }

//     /**
//      * 关闭视图。
//      * 建议方法名：closeView
//      */
//     onCloseView() {
//         this._close();
//     }
// }

import { ADMgr } from "./ADManager";
import { BundleNames } from "./BundleConfig";
import { GetItemsData } from "./Const_Hall";
import { EVENT_TYPE } from "./EvenType";
import { EventMgrInstance } from "./EventManager";
import { Excel } from "./Excel";
import { GameDataMgr } from "./GameDataManager";
import { GameGlobalVariable } from "./GameGlobalVariable";
import FruitDataManager from "./HallGlobalVariable";
import { PlayerDataMgr } from "./PlayerDataManager";
import TimeUtils from "./TimeUtils";
import { TipMgr } from "./TipsManager";
import { UIView_Game } from "./UIConfig_Game";
import { UIView_Home } from "./UIConfig_Home";
import UIManager from "./UIManager";
import UIRotate from "./UIRotate";
import UIViewBase from "./UIView";
import ViewBoxAward from "./UI_BoxAward";


const { ccclass, property } = cc._decorator;

/**
 * 建议类名：EndlessModeUI
 */
@ccclass
export default class ViewWuJinTiaoZhan extends UIViewBase {
    @property(cc.Label)
    public wujintime: cc.Label = null;

    @property(cc.Label)
    public wujinfenshu: cc.Label = null;

    @property(cc.Label)
    public wujincount: cc.Label = null;

    @property(cc.Node)
    public shaodangBt: cc.Node = null;

    @property(cc.Node)
    public awardBoxs: cc.Node = null;

    @property(cc.Node)
    public awardNode: cc.Node = null;

    @property(cc.Node)
    public startBt: cc.Node = null;

    @property(cc.Label)
    public saodangLb: cc.Label = null;

    @property(cc.Label)
    public kaishiLb: cc.Label = null;

    private tagfen: number[] = [1500, 3000, 4500, 6000];

    onEnable() {
        EventMgrInstance.addListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initializeEndlessModeUI, this);
        EventMgrInstance.addListener(EVENT_TYPE.Game_TiaoZhan_JiFen, this.initializeEndlessModeUI, this);
        EventMgrInstance.addListener(EVENT_TYPE.Game_TIAOZHAN_PASS, this.initializeEndlessModeUI, this);
        this.initializeEndlessModeUI();
    }

    onDisable() {
        EventMgrInstance.removeListener(EVENT_TYPE.Game_TiaoZhan_JiFen, this.initializeEndlessModeUI, this);
        EventMgrInstance.removeListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initializeEndlessModeUI, this);
        EventMgrInstance.removeListener(EVENT_TYPE.Game_TIAOZHAN_PASS, this.initializeEndlessModeUI, this);
    }

    protected _show(event: any, ...args: any[]) {
        // Method implementation
    }

    /**
     * 初始化无限模式UI。
     * 建议方法名：initializeEndlessModeUI
     */
    private initializeEndlessModeUI() {
        const wuJinCount = PlayerDataMgr.getWuJinCount();
        this.wujincount.string = `今日剩余${wuJinCount}次`;
        this.wujinfenshu.string = `今日累计${GameDataMgr.getChallengePoints(1)}`;

        this.shaodangBt.active = GameDataMgr.getCurrentLevelPassState(1, 1) === 1;

        this.initializeAwardBox();
        this.saodangLb.string = `×${GameGlobalVariable.wujinsaodangcount}`;
        this.kaishiLb.string = `×${GameGlobalVariable.wujintilicount}`;
    }

    /**
     * 初始化奖励盒子。
     * 建议方法名：initializeAwardBox
     */
    private initializeAwardBox() {
        const awardBoxChildren = this.awardBoxs.children;
        awardBoxChildren.forEach((box, index) => {
            const requiredScore = this.tagfen[index];
            box.children[1].getComponent(cc.Label).string = `累计${requiredScore}分`;

            this.updateBoxStatus(box, requiredScore, index);
        });
    }

    private updateBoxStatus(box: cc.Node, score: number, index: number) {
        if (GameDataMgr.getChallengePoints(1) >= score) {
            if (GameDataMgr.getChallengeAwardRecord(1, index + 1)) {
                this.setAwardBoxStatus(box, true, false, false);
                box.children[0].getComponent(UIRotate).stopRotateTween();
            } else {
                this.setAwardBoxStatus(box, false, true, true);
                box.children[0].getComponent(UIRotate).startRotateTween();
            }
        } else {
            this.setAwardBoxStatus(box, false, true, false);
            box.children[0].getComponent(UIRotate).stopRotateTween();
        }
    }

    /**
     * 设置奖励盒子的状态。
     * 建议方法名：setAwardBoxStatus
     */
    private setAwardBoxStatus(box: cc.Node, unlock: boolean, lock: boolean, redPoint: boolean) {
        box.children[0].getChildByName('unlockimg').active = unlock;
        box.children[0].getChildByName('lockimg').active = lock;
        box.children[0].getChildByName('redpoint').active = redPoint;
    }

    /**
     * 扫荡按钮点击事件。
     * 建议方法名：handleSaoDangClick
     */
    onSaoDang() {
        if (PlayerDataMgr.globalData.power >= GameGlobalVariable.wujinsaodangcount) {
            if (PlayerDataMgr.getWuJinCount() > 0) {
                ADMgr.showRewardedVideoAd('视频扫荡', () => {
                    GameGlobalVariable.nowlevel = -1;
                    GameGlobalVariable.teshulevel = 1;
                    PlayerDataMgr.subtractPower(GameGlobalVariable.wujinsaodangcount);
                    PlayerDataMgr.subtractWuJinCount(1);
                    UIManager.open(BundleNames.Game, UIView_Game.UI_GameOver, {
                        type: 2,
                        back: () => { },
                    });
                });
            } else {
                TipMgr.showToast('今日挑战次数用尽');
            }
        } else {
            TipMgr.showToast('体力不足');
        }
    }

    /**
     * 显示提示信息。
     * 建议方法名：showInformationTip
     */
    showTip() {
        UIManager.open(BundleNames.Home, UIView_Home.UI_ShuoMing);
    }

    /**
     * 开始游戏按钮点击事件。
     * 建议方法名：handleStartGameClick
     */
    onStartGame() {
        if (PlayerDataMgr.globalData.power >= GameGlobalVariable.wujintilicount) {
            if (PlayerDataMgr.getWuJinCount() > 0) {
                PlayerDataMgr.subtractPower(GameGlobalVariable.wujintilicount);
                EventMgrInstance.emitEvent(EVENT_TYPE.GAME_TIAOZHAN_VIEW);
                this._close();
            } else {
                TipMgr.showToast('今日挑战次数用尽');
            }
        } else {
            TipMgr.showToast('体力不足');
        }
    }

    /**
     * 奖励盒子点击事件。
     * 建议方法名：handleAwardBoxClick
     */
    onAwardBoxClick(event: cc.Event, boxIndex: string) {
        const requiredScore = this.tagfen[Number(boxIndex) - 1];
        const currentScore = GameDataMgr.getChallengePoints(1);
        const awardData = Excel.shuiguoguanqia(5);

        if (currentScore < requiredScore) {
            this.awardNode.getComponent(ViewBoxAward).displayAward(event.getCurrentTarget(), awardData, boxIndex, 2);
        } else if (GameDataMgr.getChallengeAwardRecord(1, Number(boxIndex))) {
            TipMgr.showToast('已领取');
        } else {
            TipMgr.showToast('恭喜获得奖励');
            this.getAwardDataByBoxIndex(awardData, boxIndex);
            GameDataMgr.updateChallengeAwardRecord(1, Number(boxIndex));
            this.initializeAwardBox();
        }
    }

    /**
     * 根据箱子索引获取奖励数据。
     * 建议方法名：getAwardDataByBoxIndex
     */
    private getAwardDataByBoxIndex(data: any, boxIndex: string) {
        switch (boxIndex) {
            case '1':
                this.getAwardData(data.tiaozhanbox1);
                break;
            case '2':
                this.getAwardData(data.tiaozhanbox2);
                break;
            case '3':
                this.getAwardData(data.tiaozhanbox3);
                break;
            case '4':
                this.getAwardData(data.tiaozhanbox4);
        }
    }

    /**
     * 获取奖励数据。
     * 建议方法名：fetchAwardData
     */
    private getAwardData(dataArray: any[]) {
        let awardData = new GetItemsData();
        awardData.ids = [];
        awardData.counts = [];

        dataArray.forEach((data) => {
            const [type, count, fragment] = data;
            switch (type) {
                case 1:
                    awardData.ids.push(FruitDataManager.goldId);
                    awardData.counts.push(count);
                    break;
                case 2:
                    awardData.ids.push(FruitDataManager.diamondId);
                    awardData.counts.push(count);
                    break;
                case 3:
                    awardData.ids.push(FruitDataManager.powerId);
                    awardData.counts.push(count);
                    break;
                case 5:
                    const fragments = this.getFragmentData(fragment);
                    fragments.forEach((fragmentCount, id) => {
                        awardData.ids.push(id);
                        awardData.counts.push(fragmentCount);
                    });
                    break;
            }
        });

        awardData.clickCallBack = this.createAwardCallback(awardData);
        UIManager.open(BundleNames.Home, UIView_Home.UI_GetItems, awardData);
    }

    private getFragmentData(fragment: any): Map<number, number> {
        let fragmentData: Map<number, number> = new Map();
        if (fragment === 1) {
            fragmentData = FruitDataManager.getSuiPian([fragment, 0, 0]);
        } else if (fragment === 2) {
            fragmentData = FruitDataManager.getSuiPian([0, fragment, 0]);
        } else if (fragment === 3) {
            fragmentData = FruitDataManager.getSuiPian([0, 0, fragment]);
        }
        return fragmentData;
    }

    private createAwardCallback(awardData: GetItemsData): () => void {
        return () => {
            awardData.ids.forEach((id: number, index: number) => {
                const count = awardData.counts[index];
                this.dispatchAwardEvent(id, count);
            });
        };
    }

    private dispatchAwardEvent(id: number, count: number) {
        switch (id) {
            case FruitDataManager.goldId:
                EventMgrInstance.emitEvent(EVENT_TYPE.Home_Add_Gold, 2, count);
                break;
            case FruitDataManager.diamondId:
                EventMgrInstance.emitEvent(EVENT_TYPE.Home_Add_Gold, 3, count);
                break;
            case FruitDataManager.powerId:
                EventMgrInstance.emitEvent(EVENT_TYPE.Home_Add_Gold, 1, count);
                break;
            default:
                TipMgr.showToast('恭喜获得水果碎片');
                PlayerDataMgr.addEquipFragments(id, count);
        }
    }

    /**
     * 更新方法。
     * 建议方法名：updateRemainingTime
     */
    update() {
        this.wujintime.string = `${TimeUtils.convertSecondsToHMS(TimeUtils.getMillisecondsUntilMidnight() / 1000)}刷新`;
    }

    /**
     * 关闭视图。
     * 建议方法名：closeView
     */
    onCloseView() {
        this._close();
    }
}